<template>
  <!-- 题库贡献者列表 -->
  <Loading :isSpin="loading">
    <div class="content">
      <!--  分类介绍    -->
      <div class="introduce">
      </div>
      <wave/>
      <div class="gray-bk">
        <div class="layout">
          <div class="userlist">
            <div class="user" v-for="(item, index) in list" :key="item.id" @click="StartTopic(item.id)">
              <!--    头像    -->
              <a-popover title="Title">
                <template #content>
                  <p>Content</p>
                  <p>Content</p>
                </template>
                <!--   TODO 这里还没集成用户,有用户后需要修改       -->
                <img src="@/assets/icon/topicList/java.png" alt="">
              </a-popover>

              <!--  发布时间       -->
              <div class="topicDate">
                {{item.createTime}}
              </div>

              <div class="userIntroduce">
              <!--   标题     -->
                <h1>{{item.title}}</h1>
              <!--   题库的简介     -->
              <!--   TODO 记得加超出省略号        -->
                <p>{{item.topicDescribe}}</p>
              </div>
              <!--   收藏    -->
              <a-rate value="1" count="1" >
                <template #character>
                  <heart-outlined />
                </template>
              </a-rate>
            </div>
          </div>
        </div>
      </div>
    </div>
  </Loading>
</template>

<script setup lang="ts">
import { HeartOutlined } from '@ant-design/icons-vue';
import {ref} from "vue";
import {queryConurseTopicList} from "@/api/conurseTopic.ts";
import router from "@/router";
import Wave from "@/components/wave.vue";
import Loading from "@/components/loading.vue";

let props = defineProps(['secondId'])
let list = ref<TopicCartClass[]>([])
let loading = ref<boolean>(false)


const initMethod = () => {
  getConurseTopicList(props.secondId)
}
const getConurseTopicList = async (id:number) => {
  loading.value = true
  let {data: {data}} = await queryConurseTopicList(id)
  list.value = data
  loading.value = false

}
initMethod()

// 题型单击事件
const StartTopic = (id:number) => {
  router.push('/do/' + id)

}
</script>

<style scoped>
  * {
    margin: 0;
    padding: 0;
  }
  .content {

    .introduce {
      height: 5rem;
      box-sizing: border-box;
      background-color: rgb(0 96 224 / 1);

      h1, h4 {
        position: relative;
        font-size: 1.4rem;
        color: white;
        top: 50%;
        left: .4rem;
        letter-spacing: .04rem;
        transform: translateY(-50%);
      }

      h4 {
        height: 0.6rem;
        width: 1.56rem;
        border-radius: 0.22rem;
        font-size: 0.3rem;
        line-height: 0.6rem;
        text-align: center;
        background-color: rgb(59 130 246 / 1);
      }
      }
    }

    .gray-bk {
      /*
      background: linear-gradient(60deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.5) 100%, rgba(255,255,255,0.3) 100%);
      */
      background-color: var(--ware-chil4-color);
    }
    .layout {
      min-height: calc(100vh - 1.32rem - 3.6rem - 1.2rem);
      width: 20.4rem;
      margin: 0 auto;
      padding-top: .5rem;
      padding-bottom: .5rem;


      .userlist {
        border: 1px solid var(--hello-border);
        border-radius: 0.12rem;
        background-color: var(--ware-chil4-color);

        .user {
          position: relative;
          height: 2.5rem;
          margin: 0 0.7rem ;
          padding: 0 0.2rem;
          display: flex;
          align-items: center;
          flex-direction: row;
          border-bottom: 1px solid var(--tabs-border-color);



          img {
            height: 1.2rem;
            width: 1.2rem;
            border-radius: 50%;
            border: 1px solid #dcdcdc;
            margin-left: 0.3rem;
            transition: all .4s;
          }


          .userIntroduce {
            flex: 1;
            padding-left: 0.4rem;
            box-sizing: border-box;
            margin-bottom: 0.2rem;

            h1 {
              font-size: 0.32rem;
              font-weight: bold;
              color: var(--user-name-color);
              transition: all .4s;
            }

            p {
              margin-top: 0.2rem;
              padding-right: 0.3rem;
              font-size: 0.24rem;
              color: var(--card-briefing-color);
              transition: all .4s;
            }
          }

          .topicDate {
            position: absolute;
            left: 0.2rem;
            bottom: .07rem;
            font-size: 0.24rem;
            color: var(--card-briefing-color);
          }
        }

        .user:hover img,
        .user:hover .userIntroduce h1,
        .user:hover .userIntroduce p {
          cursor: pointer;
          transform: translateX(0.16rem); /* 注意：transform可能会影响布局，确保这是您想要的效果 */
        }

      }
    }

</style>